package com.topvision.myviewtest.kotlin.part1

/**
 *
 * @author lucy
 * @date 2018-06-04 16:55
 * @description //TODO
 */

// 对一个对象实例调用多个方法 (with)

class Turtle {
    fun penDown() {}
    fun penUp() {}
    fun turn(degress: Double) {}
    fun forward(pixels: Double) {}
}

fun main(args: Array<String>) {
    val turle = Turtle()
    // 画个正方形
    with(turle) {
        penDown()
        for (i in 1..4) {
            forward(100.0)
            turn(90.0)
        }
        penUp()
    }
}